﻿<%@ Page Language="C#" AutoEventWireup="false" Trace="false" %>
<%@ Import Namespace="System.Collections.Generic"%>
<%@ Import Namespace="com.bodurov.SessionRecovery"%>
<script runat="server">
/*
 * This page can be used as a temporary tool for 
 * enabling and disabling the session recovery manager.
 * Please change the password..
 */
private const string PASSWORD = "secretpassword001";
private void BindControl(object sender, EventArgs e)
{
    ((Control) sender).DataBind();
}
private void ToggleSessionRecovery(object sender, EventArgs e)
{
    if (Pass.Text != PASSWORD)
    {
        this.Errors.Text = "Wrong Password";
        return;
    }

    Sessions.Manager.IsEnabled = !Sessions.Manager.IsEnabled;
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Test</title>
    <style>
    * {
      font-family: Georgia;
    }
    </style>
    <script type="text/javascript">
    function RefreshUnique()
    {
        var loc = document.location.href;
        var qmIndex = loc.indexOf('?');
        if (qmIndex > 0) {
            loc = loc.substr(0, qmIndex);
        }
        document.location.href = loc + "?u=" + (new Date()).getTime();
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <span style="color:red">
          <asp:Label runat="server" ID="Errors" EnableViewState="false" />
        </span>
        <div>
            Session Recovery is
            <strong>
                <asp:Label runat="server" OnPreRender="BindControl" 
                     Text='<%#Sessions.Manager.IsEnabled?"Enabled":"Disabled"%>' />
            </strong>
            Password <asp:TextBox runat="server" ID="Pass" />
            <asp:Button runat="server" OnPreRender="BindControl" OnClick="ToggleSessionRecovery"
                 Text='<%#Sessions.Manager.IsEnabled?"Disable!":"Enable!"%>' />
            <input type="button" value="Refresh The Page" onclick="RefreshUnique();return false;" />
        </div>
    </form>
</body>
</html>
